package com.hehe.conversion.hehemiddleware.common;

/**
 * 合合与睿真票据类型对应
 */
public enum InvoiceType {

    VAT_SPECIAL_INVOICE("增值税专用发票", 10100),
    VAT_COMMON_INVOICE("增值税普通发票", 10101),
    BLOCKCHAIN_ELECTRONIC_INVOICE("区块链电子发票", 10102),
    VAT_ELECTRONIC_SPECIAL_INVOICE("增值税电子专用发票", 10100),
    VAT_ELECTRONIC_INVOICE("增值税电子普通发票", 10102),
    VAT_ELECTRONIC_INVOICE_NEW("电子发票普通发票", 10108),
    VAT_ELECTRONIC_SPECIAL_INVOICE_NEW("电子发票专用发票", 10107),
    VAT_ELECTRONIC_TOLL_INVOICE("增值税电子普通发票(通行费)", 10109),
    VAT_ROLL_INVOICE("卷票", 10103),
    MOTOR_VEHICLE_SALE_INVOICE("机动车销售统一发票", 10104),
    USED_CAR_PURCHASE_INVOICE("二手车销售统一发票", 10105),
    QUOTA_INVOICE("定额发票", 10200),
    TAXI_TICKET("出租车", 10500),
    TRAIN_TICKET("火车票", 10503),
    PASSENGER_TRANSPORT_INVOICE("客运汽车", 10505),
    AIR_TRANSPORT("航空运输电子客票行程单", 10506),
    VEHICLE_TOLL("过路费发票", 10507),
    SHOP_RECEIPT("消费小票", 20100),
    MACHINE_PRINTED_INVOICE("机打发票", 10400),
    GENERAL_MACHINE_INVOICE("通用机打发票", 10400),
    MEDICAL_RECEIPT("医疗票据", 102021),
    NON_TAX_INCOME_UNIFIED_BILL("非税收入类票据", 102015);

    private final String description;
    private final int code;

    InvoiceType(String description, int code) {
        this.description = description;
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public int getCode() {
        return code;
    }

    public static InvoiceType fromCode(int code) {
        for (InvoiceType type : values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        return null;
    }
    public static InvoiceType fromString(String text) {
        for (InvoiceType b : InvoiceType.values()) {
            if (b.name().equalsIgnoreCase(text)) {
                return b;
            }
        }
        return null;
    }
}

